<html>
<title>filter</title>

<head>
    <script src="./js/vue.js"></script>
    <script>
        //全局过滤器
        Vue.filter('addZero', function (data) {
            return data < 10 ? ('0' + data) : data;
        })
        window.onload = function () {
            let app = new Vue({
                el: '.container',
                data: {

                },
                methods: {

                },
                // 局部过滤器
                filters: {
                    roundNumber: (data, n) => {
                        return data.toFixed(n);
                    }
                }
            })
        }
    </script>
</head>

<body>
    <div class="container">
        <h3>{{ 3.1415926 | roundNumber(3) }}</h3>
        <h3>{{ 3 | addZero }}</h3>
    </div>
</body>

</html>